interface ICheckAuthScope {
  scope: string;
  label: string;
}
async function checkAuthScope(props: ICheckAuthScope) {
  try {
    await uni.authorize({ scope: props.scope });
  } catch (error) {
    await settingAuth(props);
  }
}
async function settingAuth(props: ICheckAuthScope) {
  const confirm = (await uni.showModal({
    title: "授权确认",
    showCancel: true,
    cancelText: "取消",
    confirmText: "授权",
    content: props.label,
  })) as any;
  if (confirm.cancel) return;
  const res = await uni.openSetting({});
  // errMsg: "openSetting:ok"
  // authSetting.scope.writePhotosAlbum // true || false
}

export { checkAuthScope };
